<?php

namespace app\model\pms;

use think\Model;

/**
 * t_goods_spec 商品规格表
 * @property integer $id 商品规格id(主键)
 * @property integer $goods_id 商品id
 * @property string $spec 自定义规格
 */
class GoodsSpec extends Model
{
    /**
     * The connection name for the model.
     *
     * @var string|null
     */
    protected $connection = 'mysql';
    
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 't_goods_spec';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $pk = 'id';

    public function setSpecAttr($value)
    {
        $value = json_encode($value, JSON_UNESCAPED_UNICODE);
        return $value;
    }

    public function getSpecAttr($value)
    {
        return json_decode($value ?? "{}", true) ?? [];

    }
}
